#include <iostream>
using namespace std;
class Date
{
public:
    Date(int year, int month, int day)
    {
        _year = year;
        _month = month;
        _day = day;
    }
    int day()
    {
        int a[] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
        if ((_year % 4 == 0 && _year % 100 != 0) || _year % 400 == 0)
            a[2] = 29;
        int n = 0;
        for (int i = 1; i < _month; i++)
        {
            n += a[i];
        }
        return n + _day;
    }
private:
    int _year;
    int _month;
    int _day;
};
int main()
{
    int a, b, d;
    cin >> a >> b >> d;
    Date c(a, b, d);
    cout << c.day() << endl;
}